package com.yb.oldlearning;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * CachedThreadPool在程序执行中会创建与所需数量相同的线程，并在回收旧的线程时会停止创建新的线程
 * 创建执行器的首选
 * @author Administrator
 */
public class CachedThreadPool {
	public static void main(String[] args) {
		ExecutorService exec = Executors.newCachedThreadPool();
		for (int i = 0; i < 3; i++) {
			exec.execute(new LiftOff());
		}
		exec.shutdown();
	}
}

